import {crmStore} from '@CRM/store'

// 根据type获取crm系统字典
export const getCrmDict = async(types) => {
  await crmStore.dispatch('dictionary/getDictionary', types)
  return crmStore.getters['dictionary/getDictionary']
}
// 根据key获取显示label
export const getCrmDictLabel = (type, value) => {
  if (crmStore.getters['dictionary/getDictionary'] && crmStore.getters['dictionary/getDictionary'][type]) {
    var dictList = crmStore.getters['dictionary/getDictionary'][type]
    var item = dictList.find(p => p.value === value)
    if (item) {
      return item.label
    } else {
      return ''
    }
  } else {
    return ''
  }
}
